﻿package uk.co.revisual.puremvc.loader.deconstructors
{
	
	import flash.display.Bitmap;
	import flash.display.DisplayObject;
	
	import uk.co.revisual.puremvc.loader.interfaces.*;
	import uk.co.revisual.puremvc.loader.interfaces.IDeconstruct;
	
	/**
	* ...
	* @author DefaultUser (Tools -> Custom Arguments...)
	*/
	public class  DisplayObjectDeconstructor implements IDeconstruct
	{
		private var mDO:DisplayObject;
		private var mDeconstructor:IDeconstruct;
		
		public function DisplayObjectDeconstructor(d:DisplayObject):void
		{
			mDO = d;
			init();
		}
		
		public function deconstruct():void
		{
			if(mDeconstructor)
			{
				mDeconstructor.deconstruct();
				mDeconstructor = null;
			}
			
			mDO = null;
		}
		
		private function init():void
		{
			
			switch(true)
			{
				case(mDO is Bitmap):
					mDeconstructor = new BMPDeconstructor(Bitmap(mDO));
					break;
				
				default:
					
			}
			
			
		}
		
	}
	
}